package com.hanliukui.ai.langchain4j.assistant.general;


import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.service.AiServices;
import dev.langchain4j.store.memory.chat.ChatMemoryStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GeneralAssistantConfig {

    @Bean
    public GeneralAssistant simpleChatAssistant(ChatModel chatModel, ChatMemoryStore chatMemoryStore
    ) {
        return AiServices.builder(GeneralAssistant.class)
                .chatModel(chatModel)
                .chatMemoryProvider((mid) -> MessageWindowChatMemory.builder()
                        .id(mid)
                        .chatMemoryStore(chatMemoryStore).maxMessages(10).build())
                .build();
    }
}
